<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

class ShopController extends Controller
{
    public function show()
    {
        return view('shop');
        // 写法一
        //return view('home/test/show');
        //写法二(新)
        // return view('home.test.show');
    }
    public function avatar()
    {
        return view('avatr');
    }
    public function up(Request $request)
    {
        // 判断有没有
        if ($request->hasFile('avatar')) {
            // 获取上传
            $avatar = $request->file('avatar');
            if ($avatar->isValid()) {
                $name = md5(microtime(true)) . '.' . $avatar->extension();
                $avatar->move('static/upload', $name);
                $parh = '/static/upload/' . $name;
                return '<a href="' . $parh . '">查看文件</a>';
            }
            return $avatar->getErrorMessage();
        }
        return '上传失败';
    }
}
